<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="~{common/header :: commonHead}"></head>
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="ibox-tools">
                        <a href="/consumption_quota/add" title="添加"><i class="glyphicon glyphicon-plus-sign"></i></a>
                        <a href="javascript: window.location.href='/consumption_quota/list';" title="刷新"><i
                                class="glyphicon glyphicon-repeat"></i></a>
                    </div>
                    <div class="col-sm-3">
                        <div class="input-daterange input-group" id="datepicker">
                            <shiro:hasPermission name="update_consumption_quota">
                                <button th:with="id=${switch?.get(0).id},status=${switch?.get(0).consumptionQuota}" th:onclick="changeStatus([[${id}]],[[${status}]]);" id="changeStatus" th:class="'btn btn-xs ' + ${status?'btn-primary':'btn-danger'}" th:text="${status?'启用':'禁用'}"></button>
                            </shiro:hasPermission>
                        </div>
                    </div>
                    <div id="editable_wrapper" class="dataTables_wrapper form-inline" role="grid">
                        <table class="table table-striped table-bordered table-hover  dataTable" id="editable"
                               aria-describedby="editable_info">
                            <thead>
                            <tr role="row">
                                <th aria-label="满额规则名称" style="width: 10%;">满额规则名称</th>
                                <th aria-label="满额阀值" style="width: 15%;">满额阀值</th>
                                <th aria-label="满额规则类型" style="width: 10%;">满额规则类型</th>
                                <th aria-label="满额规则创建时间" style="width: 10%;">满额规则创建时间</th>
                                <th aria-label="操作" style="width: 10%;">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr class="gradeA odd" th:if="${#lists.isEmpty(pageObj)}">
                                <td colspan="9" style="text-align: center">
                                    没有数据o&gt;^&lt;o
                                </td>
                            </tr>
                            <tr class="gradeA odd" th:each="item : ${pageObj.list}">
                                <td th:text="${item.threshoidName}"></td>
                                <td th:text="${item.threshoid}"></td>
                                <td th:text="${item.marketingType == 'integral'? '送积分':(item.marketingType == 'coupon' ? '送优惠券':'送停车券') }"></td>
                                <td th:text="${item.createTime}"></td>
                                <td class="center ">
                                    <shiro:hasPermission name="edit_consumption_quota">
                                        <a type="button" th:href="${'/consumption_quota/edit?id=' + item.consumptionId}" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
                                    </shiro:hasPermission>
                                    <a type="button" th:href="${'/consumption_quota/delete?id=' + item.consumptionId}" title="删除"><i class="glyphicon glyphicon-trash"></i></a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script th:inline="javascript">

    function changeStatus(id,status) {
        $.ajax({
            url: "/marking_rule/updateStatus",
            type: "get",
            data: {id:id,status:status},
            success:function (data) {
                if (data.resCode == 0) {
                    layer.msg("操作成功",{icon: 1,time: 1000,shade : [0.5 , '#000' , true]});
                    window.location.reload();
                } else {
                    layer.msg(data.resMsg,{icon: 1,time: 1000,shade : [0.5 , '#000' , true]});
                }
            }
        });
    }
</script>
</html>